import { ref } from "vue"
import store from "@/store"
import { defineStore } from "pinia"
import { getAgencyDataApi } from "@/api/agency"
export const useReStore = defineStore(
  "re",
  () => {
    const reListStore = ref<string[]>([])
    /** 设置职位列表 */
    const setReList = (value: string[]) => {
      reListStore.value = value
    }
    const getReFn = async () => {
      await getAgencyDataApi({
        page: 1,
        size: 1000
      }).then((res: any) => {
        setReList(res.data.list)
      })
    }

    return {
      reListStore,
      setReList,
      getReFn
    }
  },
  {
    persist: {
      enabled: true,
      strategies: [
        {
          storage: localStorage
          // paths: ["jobListStore", "authListStore"] //指定要长久化的字段
        }
      ]
    }
  }
)
/** 在 setup 外使用 */
export function useReStoreHook() {
  return useReStore(store)
}
